#!/bin/bash


:<<EOF
    封装这个功能作为一个函数,  来 加载 CSV 文件到 mysql中
EOF




# 构造函数
# @param  csvpath
# @param  table
# @param  columns
# @param  env
# @param  extend_part
#
function  LoadcsvFunction(){


    local  csvpath=$1
    local  table=$2
    local  columns=$3
    local  env=$4
    local  extend_part=$5

    local script_path=$(dirname "$0")
    BuildCommandSql=$script_path"/""BuildCommandSql.sh"
    source  "$BuildCommandSql"


    BuildCommandSql  "'${csvpath}'"  "${table}"   "${columns}"  "${extend_part}"

    local config_file_path=$(dirname "$script_path")/config

    if [[   ${env} = "prod" ]]; then
        config_file=$config_file_path/mysql_client_prod.conf
    elif [[  ${env} = "dev"   ]]; then
        config_file=$config_file_path/mysql_client_dev.conf
    else
        config_file=$config_file_path/mysql_client_local_dev.conf
    fi

    echo  "执行sql ==>  ${FINAL_SQL}"
    $(mysql --defaults-file="$config_file" -e "$FINAL_SQL")
    if [ $? -ne 0 ]; then
        echo "执行   failed"    # todo 处理相应结果
    else
        echo "执行   succeed"   # 发送消息
    fi

}









